#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ll.h"
#include "memory.h"

LL *root;

LL *initializeLL(char *ID){
	root= NEW(LL);
	root->ID= malloc(strlen(ID));
	strcpy(root->ID, ID);
	root->previous= NULL;
	root->next= NULL;
	return root;
}

LL *insertLL(char *ID){
	LL *temp;
	LL *llelement= NEW(LL);
	llelement->ID= malloc(strlen(ID));
	strcpy(llelement->ID, ID);
	llelement->next= NULL;
	temp=root;

	while(temp->next!= NULL){
		temp= temp->next;
	}

	temp->next= llelement;
	llelement->previous= temp;
	return llelement;
}

LL *getLL(char *ID){
	LL *temp=root;
	while(strcmp(temp->ID,ID)!=0 || temp->next!= NULL){
		temp=temp->next;
	}
	if(strcmp(temp->ID,ID)!=0){
		return temp;
	}else{
		return NULL;
	}
}
